package com.atguigu.gulimall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gulimall.product.entity.BaseSaleAttr;
import com.atguigu.gulimall.product.entity.SpuSaleAttr;
import com.atguigu.gulimall.product.service.BaseSaleAttrService;
import com.atguigu.gulimall.product.service.SpuSaleAttrService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author nicc
 * @version 1.0
 * @className SaleAttrController
 * @description TODO
 * @date 2022-09-29 09:17
 */
@Api(tags = "销售信息接口")
@RequestMapping("/admin/product")
@RestController
public class SaleAttrController {

    @Autowired
    private BaseSaleAttrService baseSaleAttrService;

    @Autowired
    private SpuSaleAttrService spuSaleAttrService;


    @GetMapping("/baseSaleAttrList")
    public Result getBaseSaleAttrList(){
        List<BaseSaleAttr> list = baseSaleAttrService.list();
        return Result.ok(list);
    }

    @GetMapping("/spuSaleAttrList/{spuId}")
    public Result getSpuSaleAttrList(@PathVariable("spuId") Long spuId){

        List<SpuSaleAttr> spuSaleAttrs = spuSaleAttrService.getSpuSaleAttrList(spuId);

        return Result.ok(spuSaleAttrs);
    }

}